{include file=header.html}
<script language="javascript" type="text/javascript" src="{res file=DatePicker/WdatePicker.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/jquery-1.2.6.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/common.js}"></script>
<script language="javascript" type="text/javascript">
$(function() {
$('th[type="order"]').click(function() {
var order = $(this).attr('field') + '-' + $(this).attr('order');
$('#order').val(order);
$('input[name="search"]').click();
}).css({'cursor': 'pointer', 'color': '#36c'});
var order = $('#order').val().split('-');
var field = $('th[type="order"][field="' + order[0] + '"]');
if (order[1] == 'ASC') {
field.attr('order', 'DESC').text(field.text() + '↑');
} else {
field.attr('order', 'ASC').text(field.text() + '↓');
}
if (order[0] != 'arrival_date') {
$('th[type="order"][field="arrival_date"]').attr('order', 'DESC');
}

/* 
$("#brand_id").change(function(){
$(this).blur();
})
$("#brand_id").blur(function(){
var brand_id = $("#brand_id").val();
var url="index.php?app=sample&act=ajax_get_buyer&id="+brand_id;
$.getJSON(url,function(ret){
if(ret)
{
$("#buyer_id option").remove();
$("#buyer_id").append('<option value="0"></option>');
for(i in ret)
{
$("#buyer_id").append('<option value="'+ret[i]['user_id']+'" >'+ret[i]['user_name']+'</option>');
}
}
});
}) */

$("#fabric_shop_id").change(function(){
var brand_id = $(this).val();
var url="index.php?app=sample&act=ajax_get_fabric_shop&id="+brand_id;
$.getJSON(url,function(ret){
if(ret)
{
$("#factory_item option").remove();
$("#factory_item").append('<option value="-1"></option>');
$.each(ret, function(k, v) {
$("#factory_item").append('<option value="'+v+'" >'+v+'</option>');

});
}
});
})


});

$(function(){
	//取消用户分配
	$('#cancel_batch').click(function(){
		if(confirm("您确定要取消全部的模板分配吗?")==true){
			window.location = "index.php?app=sample&act=batch_cancel";
			return true;
		}else{
			return false;
		}
	});
	
	//取消展示样板
	$('#cancel_show').click(function(){
		if(confirm("您确定要取消全部的展示样板吗?")==true){
			window.location = "index.php?app=sample&act=reveal_cancel";
			return true;
		}else{
			return false;
		}
	});
});
</script>
<body>
<!--收起展开 开始 --> 
<!--<div class="sub-body" style="padding:20px 25px 0 25px;">
<a href="" onClick="$('#search_box').slideToggle();return false;">收起/展开</a>
</div> --> 
<!--收起展开 结束 -->
<div class="sub-body" id="search_box">
	<h3 class="title-1" style="display:none;">样板查询</h3>
	<form method="get" action="{url app=sample&act=search}">
		<input type="hidden" name="app" value="sample">
		<input type="hidden" name="act" value="search">
		<!-- {if $user.role==USER_CLIENT} -->
		<table width="80%" cellpadding="0" cellspacing="0" class="search" >
	      <tr>
	        <th width="100">板号：</th>
	        <td width="160"><input type="text" name="sample_sn" class="input-1" value="{$smarty.get.sample_sn}"/></td>
	 
	        <th width="100">状态：</th>
	        <td width="160"><select name="status">
	        	<option value="-1"></option>
	        	<!--{foreach from=$lang.statuies item=item key=k}-->
	              {if !in_array($k,array(99))}
	              <option value="{$k}" {if $k == $smarty.get.status}selected{/if}>{$item}</option>
	              {/if}
	        	<!--{/foreach}-->
	        	</select></td>
	            <th>品牌：</th>
		        <td><select name="brand_id" id="brand_id">
		          <option value="0"></option>
				  <!--{foreach from=$brand_list item=brand}-->
		          <option value="{$brand.brand_id}" {if $brand.brand_id == $smarty.get.brand_id}selected{/if}>{$brand.brand_name|escape}&nbsp;&nbsp;({$brand.company_name|escape})</option>
				  <!--{/foreach}-->
		        </select></td>    
	                <td rowspan="2" width="100"><input name="search" type="submit" class="inquiry" value="{$lang.search}"/><!--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class="btn-2" value="清空条件" acttype="clear">--><input type="hidden" id="order" name="order" value="{if $smarty.get.order}{$smarty.get.order}{else}arrival_date-DESC{/if}" /></td>
	      </tr>
	    
	      <tr>
	        <th>买手：</th>
	        <td><select name="buyer_id" id="buyer_id">
	          <option value="0"></option>
			  <!--{foreach from=$buyer_list item=buyer}-->
	          <option value="{$buyer.user_id}" {if $buyer.user_id == $user.user_id}selected{/if}>{$buyer.user_name|escape}</option>
			  <!--{/foreach}-->
	        </select></td>
	        <th>跟单：</th>
	      	<td><select name="merch_id">
	      		<option value="0"></option>
	      		<!--{foreach from=$merchandiser_list item=merch}-->
	      		<option value="{$merch.user_id}"{if $merch.user_id == $smarty.get.merch_id} selected{/if}>{$merch.user_name}</option>
	      		<!--{/foreach}-->
	      		</select></td>	
	
			<th>&nbsp;</th>
			<td>&nbsp;</td>
	        
	        </tr>
	
	
	    </table>
		<!-- {else} -->
	    <table width="80%" cellspacing="0" cellpadding="0" class="search" >
			<tr>
				<th width="100">到板日期：</th>
				<td width="200"><input type="text" name="arrival_date_start" class="input-6" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="{$smarty.get.arrival_date_start}" />
					至
					<input type="text" name="arrival_date_end" class="input-6" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="{$smarty.get.arrival_date_end}"/></td>
				<th width="100">板&nbsp;&nbsp;&nbsp; 号：</th>
				<td width="200"><input type="text" name="sample_sn" class="input-1" value="{$smarty.get.sample_sn}"/></td>
				<th width="100">品&nbsp;&nbsp;&nbsp; 牌：</th>
				<td width="200"><select name="brand_id" id="brand_id" {if $user.role eq USER_FACTORY}disabled="disabled"{/if}>
						<option value="0"></option>
						<!--{foreach from=$brand_list item=brand}-->
						<option value="{$brand.brand_id}" {if $brand.brand_id == $smarty.get.brand_id}selected{/if}>{$brand.brand_name|escape}&nbsp;&nbsp;({$brand.company_name|escape})</option>
						<!--{/foreach}-->
					</select></td>
				<td width="100" rowspan="4"><input name="search" type="submit" class="inquiry" value="{$lang.search}"/><input type="hidden" id="order" name="order" value="{if $smarty.get.order}{$smarty.get.order}{else}arrival_date-DESC{/if}" /></td>
			</tr>
			<tr>
				<th>买&nbsp;&nbsp;&nbsp; 手：</th>
				<td><select name="buyer_id" id="buyer_id" {if $user.role eq USER_FACTORY}disabled="disabled"{/if}>
						<option value="0"></option>
						<!--{foreach from=$buyer_list item=buyer}-->
						<option value="{$buyer.user_id}" {if $buyer.user_id == $smarty.get.buyer_id}selected{/if}>{$buyer.user_name|escape}</option>
						<!--{/foreach}-->
					</select></td>
				<th>跟&nbsp;&nbsp;&nbsp; 单：</th>
				<td><select name="merchandiser_id">
						<option value="0"></option>
						<!--{foreach from=$merch_list item=merch}-->
						<option value="{$merch.user_id}" {if $merch.user_id == $smarty.get.merchandiser_id}selected{/if}>{$merch.user_name|escape}</option>
						<!--{/foreach}-->
					</select></td>
				<th>状&nbsp;&nbsp;&nbsp; 态：</th>
				<td><select name="status">
        	<option value="-1"></option>
        	<!--{foreach from=$lang.statuies item=item key=k}-->
            {if $user.role eq USER_FACTORY}
              {if $k eq 5 OR $k eq 51 or $k eq 6 or $k eq 7}
              <option value="{$k}" {if $k == $smarty.get.status}selected{/if}>{$item}</option>
              {/if}
            {else}
              {if $k neq 99}
              <option value="{$k}" {if $k == $smarty.get.status}selected{/if}>{$item}</option>
              {/if}
            {/if}
        	<!--{/foreach}-->
        	</select></td>
			</tr>
			<tr>
				<th>款&nbsp;&nbsp;&nbsp;&nbsp;式：</th>
				<td><select name="style_id">
						<option value="0"></option>
						<!--{foreach from=$style_list item=style}-->
						<option value="{$style.style_id}" {if $style.style_id == $smarty.get.style_id}selected{/if}>{$style.style_name|escape}</option>
						<!--{/foreach}-->
					</select></td>
				<th>分配买手：</th>
                <td>
	                <select name="assign_buyer" id="assign_buyer" {if $user.role eq USER_FACTORY}disabled="disabled"{/if}>
						<option value="0"></option>
						<!--{foreach from=$buyer_list item=buyer}-->
						<option value="{$buyer.user_id}">{$buyer.user_name}</option>
						<!--{/foreach}-->
					</select>
				</td>
				<th>是否下单：</th>
				<td><select name="is_order">
						<option value="-1"></option>
						<option value="1" {if $smarty.get.is_order == 1}selected{/if}>{$lang.yes}</option>
						<option value="0" {if $smarty.get.is_order == 0}selected{/if}>{$lang.no}</option>
					</select></td>
			</tr>
			<tr>
				<th>工&nbsp;&nbsp;&nbsp; 厂：</th>
				<td><select name="factory_id" {if $user.is_factory eq 1} disabled {/if}>
						<option value="0"></option>
						<!--{foreach from=$factory_list item=factory}-->
						<option value="{$factory.factory_id}" {if $factory.factory_id == $user.factory_id}selected{/if}>{$factory.factory_name|escape}</option>
						<!--{/foreach}-->
					</select></td>
				<th>布行档口：</th>
				<td><select  name="fabric_shop_id" id="fabric_shop_id">
						<option value="0">{$lang.select_pls}</option>
						<!--{foreach from=$fabric_shop_list item=fabric_shop}-->
						<option value="{$fabric_shop.fabric_shop_id}" {if $fabric_shop.fabric_shop_id == $fabric_shop_id}selected{/if}>{$fabric_shop.fabric_shop_name|escape}</option>
						<!--{/foreach}-->
					</select></td>
				<th>品名货号：</th>
				<td><select name="factory_item" id="factory_item">
						<option value="-1">{$lang.select_pls}</option>
						<!-- {foreach from=$color_card_info_list item=color_card_list} -->
						<option value="{$color_card_list.item}" {if $color_card_list.item eq $factory_item} selected="selected" {/if}>{$color_card_list.item}</option>
						<!-- {/foreach} -->
					</select></td>
			</tr>
		</table>
	<!-- {/if} -->
	</form>
	<div class="tab_info">
		<div class="tab-title-1"><span>样板信息列表</span> </div>
		<table width="100%" cellspacing="0" cellpadding="0" class="tab-display" id="tab-color1">
			<!-- {if $user.role!=USER_CLIENT} -->
			<tr>
				<!-- {if ($user.role==USER_MERCHANDISER && $user.role_cate==ROLE_MERCH) || $user.role==USER_MANAGER || $user.role eq USER_CIVILIAN} -->
		      	<th width="2%"><input type="checkbox" class="checkall" /></th>
		      	<!-- {/if} -->
				<th width="3%">序号</th>
				<th width="7%" type="order" field="arrival_date" order="ASC">到板日期</th>
				<th width="7%" type="order" field="sample_sn" order="ASC">板号</th>
				<th width="7%">图片</th>
				<!-- {if $user.role neq USER_FACTORY} -->
				<th width="6%">细节图</th>
				<!-- {/if} -->
				<th width="7%" type="order" field="brand_name" order="ASC">品牌</th>
				<th width="6%" type="order" field="buyer_id" order="ASC">买手</th>
				<th width="7%" type="order" field="user_name" order="ASC">跟单</th>
				<th width="6%" type="order" field="ref_sample_style" order="ASC">参考样衣</th>
				<th width="6%" type="order" field="style_name" order="ASC">款式</th>
				<th width="6%" type="order" field="sample.status" order="ASC">状态</th>
				<th width="6%" type="order" field="factory_name" order="ASC">工厂</th>
				<th width="6%" type="order" field="sample_made_days" order="ASC">板期</th>
				<th width="6%" type="order" field="factory_price" order="ASC">工厂报价</th>
				<th width="7%">订单号</th>
				<!-- {if ($user.role==USER_MERCHANDISER && $user.role_cate==ROLE_MERCH) ||  $user.role==USER_MANAGER} -->
				<th width="7%" type="order" field="is_preset" order="ASC">系统样板</th>
				<!-- {/if} -->
			</tr>
			<!--{foreach from=$sample_list item=sample name=s}-->
			<tr style="height: 80px">
				<!-- {if ($user.role==USER_MERCHANDISER && $user.role_cate==ROLE_MERCH) ||  $user.role==USER_MANAGER || $user.role eq USER_CIVILIAN} -->
		      	<td><input type="checkbox" class="checkitem" value="{$sample.sample_id}" /></td>
		        <!-- {/if} -->
				<td>{$smarty.foreach.s.iteration|escape}</td>
				<td>{$sample.arrival_date|date:Y-m-d}</td>
				<td><a href="{url app=sample&act=show&id=$sample.sample_id}"  style="color:blue">{$sample.sample_sn|escape}</a></td>
				<td><a href="{$sample.front_pic|escape}" target="_blank"><img src="{$sample.front_pic}" width="80" style="border:none;" ></a></td>
				<!-- {if $user.role neq USER_FACTORY} -->
				<td><a href="{url app=sample&act=upload_thumb&sample_id=$sample.sample_id}" target="_blank"><img src="{$sample.default_image}" width="80" style="border:none;" ></a></td>
				<!-- {/if} -->
				<td>{$sample.brand_name|escape}</td>
				<td>{$sample.member_name|escape}</td>
				<td>{$sample.user_name}</td>
				<td>{$lang.ref_sample_styles.$sample.ref_sample_style}</td>
				<td>{$sample.style_name|escape}</td>
				<td>{$lang.statuies.$sample.status}</td>
				<td>{$sample.factory_name|escape}</td>
				<td>{$sample.sample_made_days|escape}天</td>
				<td>{$sample.factory_price|escape}</td>
				<td>{$sample.order_sn}</td>
				<!-- {if ($user.role==USER_MERCHANDISER && $user.role_cate==ROLE_MERCH) ||  $user.role==USER_MANAGER} -->
				<td><!--{if $sample.is_preset}-->{$lang.yes}<!--{else}-->{$lang.no}<!--{/if}--></td>
				<!-- {/if} -->
			</tr>
			<!--{/foreach}-->
			<!-- {else} -->
			<tr>
		        <th width="4%">{$lang.No}</th>
		        <th width="7%" type="order" field="add_time" order="ASC">{$lang.add_time}</th>
		        <th width="7%" type="order" field="sample_sn" order="ASC">{$lang.sample_sn}</th>
				<th width="7%">{$lang.ref_sample_sn}</th>
				<th width="7%">图片</th>
				<th width="7%" type="order" field="send_sample_date" order="ASC">{$lang.send_sample_date}</th>
		        <th width="7%">{$lang.brand_name}</th>
		        <th width="7%">{$lang.buyer_name}</th>
		        <th width="7%">{$lang.merchandiser}</th>
		        <th width="7%">报价</th>
		        <th width="7%" type="order" field="sample.status" order="ASC">{$lang.status}</th>
		        <th width="9%">订单号</th>
		      </tr>
			  <!--{foreach from=$sample_list item=sample name=sm}-->
		      <tr style="height: 80px">
		        <td>{$smarty.foreach.sm.iteration}</td>
		        <td>{$sample.add_time|date:Y-m-d}</td>
		        <td><a style="color:blue" href="
		         {url app=sample&act=view_sample&id=$sample.sample_id&handle=edit}
		        ">{$sample.sample_sn|escape}</a></td>
				<td>{$sample.ref_sample_sn|escape}</td>
				<td><a href="{$sample.front_pic|escape}" target="_blank"><img src="{$sample.front_pic}" width="80" style="border:none;" ></a></td>
				<td><!-- {if $sample.send_sample_date} -->{$sample.send_sample_date|date}<!-- {/if} --></td>
		        <td>{$sample.brand_name|escape}</td>
		        <td>{$sample.member_name|escape}</td>
		        <td>{$sample.user_name|escape}</td>
		        <td>{$sample.consumer_price|escape}</td>
		        <td>{$lang.statuies.$sample.status}</td>
		        <td>{$sample.order_sn|escape}</td>
		      </tr>
			  <!--{/foreach}-->
			<!-- {/if} -->
		</table>
		<!-- {if $sample_list} -->
         <div id="batchAction" style="padding-top: 10px">
	  	  <!-- {if ($user.role==USER_MERCHANDISER && $user.role_cate==ROLE_MERCH) ||  $user.role==USER_MANAGER} -->
		   <input class="btn-2 batchButton" type="button" value="{$lang.assign_sys_sample}" name="id" uri="index.php?app=sample&act=batch_edit" />&nbsp;&nbsp;
		   <input class="btn-2" type="button" value="取消全部分配" id="cancel_batch" />&nbsp;&nbsp;
		   <!-- {if $cancel_user} -->
		   <input class="btn-2 batchButton" type="button" value="{$lang.cancel_user_show}" name="id" uri="index.php?app=sample&act=cancel_user_assign&uid={$cancel_user}" presubmit="confirm('{$lang.cancel_confirm}');" />&nbsp;&nbsp;
		   <!-- {/if} -->
		   <input class="btn-2 batchButton" type="button" value="{$lang.sys_sample_assign}" name="id" uri="index.php?app=sample&act=assign_sys_sample" />&nbsp;&nbsp;
		   <input class="btn-2" type="button" value="取消展示样板" id="cancel_show" />
		  <!-- {/if} -->
		  <!-- {if $user.role eq USER_CIVILIAN} -->
		   <input class="btn-2 batchButton" type="button" value="直接归档" name="id" uri="index.php?app=sample&act=file_stock" presubmit="confirm('您确定要直接归档已选中的样板吗?');" />&nbsp;&nbsp;
		  <!-- {/if} -->
  		</div>
  		<!-- {/if} -->
  		{include file=page.html} 
	</div>
</div>
<script type="text/javascript" src="{res file=js/tab_color.js}"></script>
</body>
</html>